package com.whw.fy.controller;

import com.whw.fy.entity.Lesson;
import com.whw.fy.entity.Message;
import com.whw.fy.service.LessonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "课程模块")
@RestController
@RequestMapping("/api/lesson")
public class LessonController {
    @Resource
    private LessonService lessonService;

    @ApiOperation(value = "添加课程信息")
    @PostMapping("/one")
    public Message insert(Lesson lesson) {
        return lessonService.insertSelective(lesson);
    }

   @ApiOperation(value = "根据课程id查看课程信息")
    @GetMapping("/id")
    public Message selectById(Integer lessonId) {
        return lessonService.selectByPrimaryKey(lessonId);
    }

    @ApiOperation(value = "根据课程id修改课程信息")
    @PutMapping("/")
    public Message update(Lesson lesson) {
        return lessonService.updateByPrimaryKeySelective(lesson);
    }

    @ApiOperation(value = "根据课程id删除课程信息")
    @DeleteMapping("/")
    public Message delete(Integer lessonId) {
        return lessonService.deleteByPrimaryKey(lessonId);
    }

    @ApiOperation(value = "查询所有课程")
    @GetMapping("/all")
    public Message selectAll(){
        return lessonService.selectAll();
    }
}
